<h2>DESCRIPTION</h2>

<em>v.net</em> is used for network preparation and maintenance. Its 
main use is to create a vector network from vector lines (<em>arcs
</em>) and points (<em>nodes</em>) by creating nodes from 
intersections in a map of vector lines (<em>node</em> operator), by 
connecting a vector lines map with a points map (<em>connect</em> 
operator), and by creating new lines between pairs of vector points
(<em>arcs</em> operator).

<p>
A GIS network consists of topologically correct lines (arcs). That is, 
the lines must be connected by shared vertices where real connections exist.
In GRASS GIS you also can add nodes to the network. These are specially 
designated vertices used for analyzing network properties or computing 
cost/distance measures. That is, <b>not all vertices are treated as nodes by
default</b>. Only <em><a href="v.net.path.html">v.net.path</a></em> can use a 
network without nodes, they are required  for all the other network modules.
In GRASS, network arcs are stored in one data layer (normally layer 1) and
nodes are stored in a different data layer (normally layer 2). 

<p>
<em>v.net</em> offers two ways to add nodes to a network of arcs and one 
method to add arcs to a set of nodes:

<ol>
<li>Use the <em>connect</em> operation to create nodes from a vector 
points file and add these nodes to an existing vector network of 
arcs (i.e., lines/boundaries). This is useful when the goal is to 
analyze a set of places (points) in relation to a network--for 
example travel costs between places. Only points within the
<em>thresh</em> (threshold) distance to a line/boundary will be 
connected as network nodes. There are two ways to connect nodes. By 
default, <em>v.net</em> will create new lines connecting each point 
to the closest line of the network. If you use the <em>-s</em> flag, 
however, the new nodes will be added on the closest line of the 
network at the point closest to the point you wish to add. When using 
the <em>connect</em> operation, some lines will share the same 
category. In order to assign unique costs to each line, a new layer 
needs to be created with<br>
<!-- like this it is rather useless, still to be improved (eg as a full example below!) -->
<tt>v.category input=yourmap option=add cat=1 step=1 layer=3 output=newmap</tt><br>
followed by<br>
<tt>v.db.addtable map=newmap layer=3 table=tablename</tt>.</li>

<li>Create nodes and arcs from a vector line/boundary file using the 
<em>node</em> operation. This is useful if you are mostly interested 
in the network itself and thus you can use intersections of the 
network as start and end points. Nodes will be created at all 
intersections of two or more lines. For an <em>arc</em> that 
consists of several segments connected by vertices (the typical 
case), only the starting and ending vertices are treated as network 
nodes.</li>

<li>Create straight-line arcs between pairs of nodes with the
<em>arcs</em> option. This produces networks like those of airline 
flights between airports. It is also similar to the kind of network 
created with social networking software, making it possible to 
create georeferenced social networks.</li> 
</ol>    
    
<p>
While the arcs created with v.net will retain any attribute information
associated with the input vector line/boundary file in data layer 1, nodes
created and stored in data layer 2 will not have any associated attribute
information. 

<p>
For nodes created using the <em>connect</em> and <em>arcs</em> 
operations (methods 1 and 3 above), the nodes can be reconnected to 
the attribute table of the input vector points file using the 
attribute table manager ("manage layers" tab) or by running
<em><a href="v.db.connect.html">v.db.connect</a></em>.

<p>
For nodes created using the <em>nodes</em> operation (method 2 
above), it is possible to create an attribute table for the new 
nodes in layer 2 using the attribute table manager and connect it to 
layer 2 ("manage layers" tab) or to create a table with
<em><a href="v.db.addtable.html">v.db.addtable</a></em>, 
connect it to layer 2 with <em><a href="v.db.connect.html">v.db.connect</a></em>,
and update the new table with cat values with <em><a href="v.to.db.html">v.to.db</a></em>. 

<p>
The <em>turntable</em> operation creates a turntable  
with the costs for every possible 
turn on every possible node (intersection, crossroad) in given layer (arc_layer). 
U-turns are taken in account too.
Turntable is created in <b>turn_layer</b> and <b>turn_cat_layer</b>.
Building the turntable allows you to model e.g. traffic code, where some turns 
may be prohibited.
If features in analyzed network are changed, the turntable must be created again
(e.g. it includes v.net connect operation).
Turntable name consists of output vector map name + "_turntable_" + "t" + "_" + turn_layer +
 "_" + "tuc" + "_" + turn_cat_layer + "_" + "a" + "_" + arc_layer  e. g. roads_turntable_t_3_tuc_4_a_1

<p>These modules are able to work with the turntable: 
<em><a href="v.net.alloc.html">v.net.alloc</a></em>,
<em><a href="v.net.iso.html">v.net.iso</a></em>,
<em><a href="v.net.path.html">v.net.path</a></em>,
<em><a href="v.net.salesman.html">v.net.salesman</a></em><!--,-->
<!--<em><a href="v.net.steiner.html">v.net.steiner</a></em>.-->

For more information about turns in the vector network analyses see 
<a href="https://grasswiki.osgeo.org/wiki/Turns_in_the_vector_network_analysis">wiki page</a>.

<p>
Once a vector network has been created, it can be analyzed in a 
number of powerful ways using the suite of <em>v.net</em>.* modules. 
The shortest route between two nodes, following arcs, can be computed
(<em><a href="v.net.path.html">v.net.path</a></em>), as can the 
shortest route that will pass through a set of nodes and return to the 
starting node (<em><a href="v.net.salesman.html">v.net.salesman</a></em>).
Least cost routes through the network can be calculated on the basis of
distance only or on the basis of distance weighted by an attribute
associated with each arc (for example, travel speed along a network segment).
A network can be divided into concentric zones of equal travel cost around 
one or more nodes (<em><a href="v.net.iso.html">v.net.iso</a></em>) or
subdivided so that each node is surrounded by a zone in which all arcs
can be reached with the same travel costs as all arcs surrounding each
other node (<em><a href="v.net.alloc.html">v.net.alloc</a></em>).

In addition to the modules listed above, the GRASS vector networking suite
includes numerous other modules for analysis of network costs and 
connectivity. These include: 
<em><a href="v.net.allpairs.html">v.net.allpairs</a></em>, 
<em><a href="v.net.bridge.html">v.net.bridge</a></em>, 
<em><a href="v.net.centrality.html">v.net.centrality</a></em>, 
<em><a href="v.net.components.html">v.net.components</a></em>, 
<em><a href="v.net.distance.html">v.net.distance</a></em>, 
<em><a href="v.net.flow.html">v.net.flow</a></em>, 
<em><a href="v.net.spanningtree.html">v.net.spanningtree</a></em>, 
<em><a href="v.net.steiner.html">v.net.steiner</a></em>, 
<em><a href="v.net.timetable.html">v.net.timetable</a></em>, and 
<em><a href="v.net.visibility.html">v.net.visibility</a></em>.
    
<h2>NOTES</h2>

For a vector map prepared for network analysis in GRASS, nodes are 
represented by the grass-internal geometry type <em>node</em> and arcs 
by the geometry type <em>line</em>. 

If vector editing is required to modify the
graph, <em><a href="g.gui.vdigit.html">g.gui.vdigit</a></em>
or <em><a href="v.edit.html">v.edit</a></em> can be used.  See also
the <a href="lrs.html">Linear Referencing System</a> available in
GRASS GIS.

<h2>EXAMPLES</h2>

The examples are <a href="http://www.grassbook.org/datasets/datasets-3rd-edition/">North Carolina dataset</a> based.

<h3>Create nodes globally for all line ends and intersections</h3>

<div class="code"><pre>
v.net input=streets_wake output=streets_node operation=nodes
# verify result
v.category streets_node option=report
</pre></div>

<h3>Merge in nodes from a separate map within given threshold</h3>

<div class="code"><pre>
v.net input=streets_wake points=firestations out=streets_net \
      operation=connect threshold=500
# verify result
v.category streets_net option=report
</pre></div>

The nodes are stored in layer 2 unless <tt>node_layer=1</tt> is used.

<h3>Generating network for vector point map</h3>

For generating network for given vector point map an input file in the
following format is required:

<div class="code"><pre>
[category of edge] [category of start node] [category of end node]
</pre></div>

<p>
Option 1: Save the file (e.g. "points.txt") and generate the map:
<div class="code"><pre>
v.net points=geodetic_swwake_pts output=geodetic_swwake_pts_net \
      operation=arcs file=points.txt
# verify result
v.category geodetic_swwake_pts_net option=report
</pre></div>

<p>
Option 2: Read in from command line:
<div class="code"><pre>
v.net points=geodetic_swwake_pts output=geodetic_swwake_pts_net \
      operation=arcs file=- &lt;&lt; EOF
1 28000 28005
2 27945 27958
3 27886 27897
EOF

# verify result
v.category geodetic_swwake_pts_net option=report
</pre></div>

<h3>Generating network with turntable for vector point map</h3>

Following example generates a vector map with turntable:
<div class="code"><pre>
v.net operation=turntable in=railroads out=railroads_ttb
</pre></div>

<h2>SEE ALSO</h2>

<em>
<a href="g.gui.vdigit.html">g.gui.vdigit</a>,
<a href="v.edit.html">v.edit</a>,
<a href="wxGUI.vnet.html">Vector Network Analysis Tool</a>
</em>

<p>
<em>
<a href="v.net.alloc.html">v.net.alloc</a>,
<a href="v.net.allpairs.html">v.net.allpairs</a>,
<a href="v.net.bridge.html">v.net.bridge</a>,
<a href="v.net.centrality.html">v.net.centrality</a>,
<a href="v.net.components.html">v.net.components</a>,
<a href="v.net.connectivity.html">v.net.connectivity</a>,
<a href="v.net.distance.html">v.net.distance</a>,
<a href="v.net.flow.html">v.net.flow</a>,
<a href="v.net.iso.html">v.net.iso</a>,
<a href="v.net.path.html">v.net.path</a>,
<a href="v.net.salesman.html">v.net.salesman</a>
<a href="v.net.spanningtree.html">v.net.spanningtree</a>,
<a href="v.net.steiner.html">v.net.steiner</a>,
<a href="v.net.timetable.html">v.net.timetable</a>,
<a href="v.net.visibility.html">v.net.visibility</a>
</em>

<h2>AUTHORS</h2>

Radim Blazek, ITC-irst, Trento, Italy<br>

Martin Landa, FBK-irst (formerly ITC-irst), Trento, Italy and CTU in
Prague, Czech Republic (operation 'connect' and 'arcs')<br>

Markus Metz: important fixes and improvements

<h3>TURNS SUPPORT</h3>

The turns support was implemnented as part of GRASS GIS turns cost project at Czech Technical University in Prague, Czech Republic.  
Eliska Kyzlikova, Stepan Turek, Lukas Bocan and Viera Bejdova participated at the project.

Implementation: Stepan Turek 
Documentation: Lukas Bocan
Mentor: Martin Landa

<!--
<p>
<i>Last changed: $Date$</i>
-->
